package com.ssr.master.modules.impl;


import com.github.pagehelper.PageHelper;
import com.ssr.master.common.Base.PageBase;
import com.ssr.master.common.Base.PageBean;
import com.ssr.master.common.exception.RegisterException;
import com.ssr.master.common.utils.StringUtils;
import com.ssr.master.modules.dao.SysUserDao;
import com.ssr.master.modules.entity.SysUser;
import com.ssr.master.modules.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ZhangPeng
 * @Describe //todo
 * @date
 * @updateBy
 * @other
 **/
@Service("SysUserService")
public class SysUserImpl implements SysUserService {

    @Autowired
    private SysUserDao sysUserDao;


    @Override
    public SysUser get(String id) {
        SysUser sysUser = sysUserDao.get(id);
        return sysUser;
    }

    @Override
    public SysUser get(SysUser var1) {
        SysUser sysUser = sysUserDao.get(var1);
        return sysUser;
    }


    /**
     * @param sysUser
     * @return com.ssr.master.modules.entity.SysUser
     * @Description //todo 根据登录名查询用户
     * @author ZhangPeng
     * @date 2020/6/20 22:52
     * @other
     **/
    @Override
    public SysUser getByLoginName(SysUser sysUser) {
        return sysUserDao.getByLoginName(sysUser);
    }

    /**
     * @param sysUser
     * @return com.github.pagehelper.Page<com.ssr.master.modules.entity.SysUser>
     * @Description //todo 获取本机构user用户列表
     * @author ZhangPeng
     * @date 2020/7/20 16:06
     * @other
     **/
    @Override
    public PageBean<SysUser> findListPage(SysUser sysUser) throws RegisterException {
        PageBean<SysUser> pageBean = new PageBean<SysUser>();
//        //设置分页信息，分别是当前页数和每页显示的总记录数【记住：必须在mapper接口中的方法执行之前设置该分页信息】
//        PageHelper.startPage(1, 2);
//        PageBean<SysUser> pageBean = new PageBean<SysUser>(1, 2, sysUserList.size());
        Integer count = sysUserDao.findListCount(sysUser);
        List<SysUser> sysUserList = sysUserDao.findList(sysUser);
        pageBean.setTotalNum(count);
        pageBean.setItems(sysUserList);
        return pageBean;
    }

    @Override
    public List<SysUser> findList(SysUser var1) {
        return null;
    }

    @Override
    public List<SysUser> findAllList(SysUser var1) {
        return null;
    }

    @Override
    public List<SysUser> findAllList() {
        return null;
    }

    @Override
    public int insert(SysUser var1) {
        return 0;
    }

    @Override
    public int update(SysUser var1) {
        return 0;
    }

    @Override
    public int delete(String var1) {
        return 0;
    }

    @Override
    public int delete(SysUser var1) {
        return 0;
    }

    public SysUser getUser(String s) {
        SysUser sysUser = sysUserDao.getUser(s);
        return sysUser;
    }

}
